<template>
	<view>
		<view class="header">
			<p @click="fanhui">
				< </p>
		</view>
		<view class="list">
			<view class="login">
				登录
			</view>
			<view class="pwd">
				<input type="text" class="input" v-model="obj.username" name="" id="" placeholder="请输入用户名">
				<input type="password" class="input" name="" v-model="obj.password" id="" placeholder="请输入密码">
			</view>
			<view class="button" @click="add">
				<u-button 	type="#5ccc84" id="demo1">登录</u-button>
			</view>
			<view class="item">
				<p @click="tiao">注册账号</p>
				<p>忘记密码？</p>
			</view>
			<view class="icon">
				<u-icon name="weixin-circle-fill" color="green" size="40"></u-icon>
			</view>
			<view class="icon">
				<label @click="ischeck = !ischeck">
					<checkbox :ischeck="ischeck" /><text></text>
				</label>
				已阅读并同意用户协议&隐私声明
			</view>
		</view>
	</view>
</template>

<script>
	import {
		addlist,
	} from "../../api/user.js"
	export default {
		data() {
			return {
				user:uni.getStorageSync("user"),
				ischeck:false,
				obj: {
					username: "liuchangtong1",
					password: "liuchangtong1",
				}

			}
		},
		methods: {
			fanhui(){
				uni.navigateBack({
					delta:1
				})
			},
			// 跳到注册
			tiao(){
				uni.navigateTo({
					url:"/pages/zclogin/zclogin"
				})
			},
		
			//登录
			async add() {
			
				
				if(!this.ischeck==true){
					uni.showToast({
						title:"请勾选下面的用户协议"
					})
					return 
				}
				
				const res=await addlist(this.obj)
				console.log(res.code);
				if(res.code=="20000"){
					uni.setStorageSync("user",res.data)
					uni.setStorageSync("token",res.data.token)
					console.log(res);
					uni.showToast({
						title:"登录成功"
					})
					uni.reLaunch({
						url:"/pages/my/my"
					})
				}

			}


		}
	}
</script>

<style scoped lang="scss">
	* {
		box-sizing: border-box;
	}

	.icon {
		width: 600rpx;
		height: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: auto;

	}

	.item {
		width: 600rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		margin: auto;
		justify-content: space-between;
		padding-left: 30rpx;
		padding-right: 30rpx;
		margin-top: 20rpx;

		p:nth-child(1) {
			color: green;
			font-size: 30rpx
		}

		p:nth-child(2) {
			font-size: 30rpx;
			color: gray;

		}
	}

	.button {
		width: 600rpx;
		height: 100rpx;
		margin: auto;
		background-color: yellow;
		margin-top: 20rpx;
		background-color: #5ccc84;
		color: white;

		#demo1 {
			width: 600rpx;
			height: 100rpx;
			font-size: 30rpx
		}
	}

	.list {
		width: 750rpx;
		height: 1000rpx;
		background-color: #fff;
		border-top-left-radius: 32px;
		border-top-right-radius: 32px;
		margin-top: -20rpx;

		.pwd {
			width: 600rpx;
			margin: auto;

			.input {
				height: 100rpx;
				width: 600rpx;
				font-size: 30rpx;
				padding-left: 50rpx;
				margin-top: 30rpx;
				background-color: #F5F5F5;
			}
		}

		.login {
			width: 750rpx;
			height: 80rpx;
			display: flex;
			align-items: center;
			padding-left: 40rpx;
			font-size: 22px;
			color: #35404b;
		}
	}

	.header {
		width: 750rpx;
		height: 250rpx;
		background-image: linear-gradient(to right, #3DFCB1, #6ADAEA);

		p {
			padding-left: 34px;
			padding-top: 12px;
			font-size: 33px;
			color: white;
		}
	}
</style>
